<template>
	<view class="">
		<NavBar :title="navTitle" :isShowLeftBtn="true" bgColor="#ffffff">
		</NavBar>
		<view class="content" v-if="isPageShow">
			<view class="" v-if="key">
				<up-parse :content="parseText"></up-parse>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { onLoad } from "@dcloudio/uni-app";
	import NavBar from "@/components/navbar.vue"
	import { getCurrentInstance, ref } from "vue";
	const { proxy } = getCurrentInstance()
	const navTitle = ref('')
	const isPageShow = ref(false)

	onLoad((options) => {
		if (options.id) {
			key.value = options.id
			navTitle.value = options.name?options.name:'文章'
			navTitle.value = options.title
			getconfig()
		} else {
			isPageShow.value = true
			navTitle.value = '404'
		}
	})
	// 获取文本信息
	const key = ref(0)
	const parseText = ref('')
	const getconfig = () => {
		try {
			proxy.$http("common.getConfig", { id: key.value }).then((res : any) => {
				isPageShow.value = true
				if (res.code == 1) {
					parseText.value = res.data
				}
			})
		} catch (e) {
			console.log(e);
			//TODO handle the exception
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		min-height: 200rpx;
		padding: 32rpx;
	}
</style>